﻿///<jscompress sourcefile="MUtil.js" />
/* 监控工具类 */
MUtil = {
	/* 获取对象，添加前缀与后缀 */	
	getObject:function(obj,preL,preR){
		
	   var ret = "";
	   
	   if(preL == undefined){
		   preL = "";
	   }
	   if(preR == undefined){
		   preR = "";
	   }
	   
	   for( var p in obj ){
		   
		   //方法不执行操作
		   if(typeof(obj[p]) == "function"){
			   ret += "temp = "+preR + p + ";";
			   ret += preL+p+"= temp(e);"; 
		   }
		   //对象，则递归
		   else if(typeof(obj[p]) == "object"){
			   
			   //数组
			   if (typeof(obj[p].length) != "undefined"){
				   
			   }
			   
			   //对象
			   else{
				   var prL = preL + p + ".";
				   var prR = preR + p + ".";
				   ret += this.getObject(obj[p],prL,prR);
			   }
			    
		   }
		   //数组
		   
		   //其他
		   else{
			  ret += preL+p+"="+preR+p+";"; 
		   }
	   }
	   return ret;
	},
	
	/* 获取属性 */
	getProperty:function(obj,pri){
		   var ret = "";
		   
		   if(pri == undefined){
			   pri = "";
		   }
		   
		   for( var p in obj ){
			   
			   //方法不执行操作
			   if(typeof(obj[p]) == "function"){}
			   //对象，则递归
			   else if(typeof(obj[p]) == "object"){
				   
				   //数组
				   if (typeof(obj[p].length) != "undefined"){
					   
				   }
				   
				   //对象
				   else{
					   var pr = pri + p + ".";
					   ret += this.getProperty(obj[p],pr);
				   }
				    
			   }
			   //数组
			   
			   //其他
			   else{
				  ret += pri+p+"="+obj[p]+"\n"; 
			   }
		   }
		   return ret;
	},
	
	/* 获取参数信息 */
	getParemeter:function(param){
		var url = location.search; //获取url中"?"符后的字串
	    var theRequest = new Object();
	    if (url.indexOf("?") != -1) {
	      var str = url.substr(1);
	      strs = str.split("&");
	      for(var i = 0; i < strs.length; i ++) {
	         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
	      }
	    }
	    
	    if(theRequest[param] == undefined){
	    	theRequest[param] = "";
	    }
	    
	    return theRequest[param];

	},
	
	/* 获取页面根路径 */
	getRootPath:function(){
		
	    //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
	    var curWwwPath=window.document.location.href;
	    //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
	    var pathName=window.document.location.pathname;
	    var pos=curWwwPath.indexOf(pathName);
	    //获取主机地址，如： http://localhost:8083
	    var localhostPaht=curWwwPath.substring(0,pos);
	    //获取带"/"的项目名，如：/uimcardprj
	    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
	    return(localhostPaht+projectName);
		
	},
}
///<jscompress sourcefile="MonitorMsg.js" />
MonitorMsg = function(){
	this.req = {};
	this.rsp = {};
	this.serviceCode = "";
	this.classPath = "";
	this.traceId = "";
	this.self = this;	
};

MonitorMsg.prototype = {
	
	/* POST后台提交数据 */	
	post:function(){
		var self = this.self;
		if(this.url == undefined){
			this.url = MUtil.getRootPath() + "/monitorService";
		}
		
		$.ajax({
            type: "POST",
            url: this.url,
            processData: false,
            async: false,
            data: "switch_json="+this.getReq(),
            dataType: 'text', 
            success: function(data){
            	//alert(data);
            	self.rsp = eval("("+data+")");
            }
        });
	},
	
	/* 获取返回码 */
	getRspResult:function(){
		return this.rsp.action.result;
	},
	
	/* 获取返回信息 */
	getRspMsg:function(){
		return this.rsp.action.message;
	},
	
	/* 获取返回数据类型 */
	getViewType:function(){
		return this.rsp.action.viewType;
	},
	
	/* 获取请求报文 */
	getReq:function(){
/*		alert(this.classPath);
		alert(this.monitorAppAuth);*/
		this.req = "";
		this.req += "{'action':{";		
		this.req += "'serviceCode':'"+this.serviceCode+"',";
		this.req += "'traceId':'"+this.traceId+"',";
		this.req += "'classPath':'"+this.classPath+"',";
		this.req += "'monitorAppAuth':'"+this.monitorAppAuth+"'";
		//添加额外参数
		if(this.param != undefined){
			for(var i in this.param){
				this.req += ",'"+i+"':"+"'"+this.param[i]+"'";
			}
		}
		
		this.req += "}}";
		
		//alert(this.req);
		return this.req;
	},
	
	/* 设置参数 */
	setParam:function(param){
		
		if(param.serviceCode != undefined){
			this.serviceCode = param.serviceCode;
		}
		
		if(param.traceId != undefined){
			this.traceId = param.traceId;
		}
		
		if(param.url != undefined){
			this.url = param.url;
		}
			
		if(param.param != undefined){
			this.param = param.param;
		}
		
		if(param.classPath != undefined){
			this.classPath = param.classPath;
		}
		
		if(param.monitorAppAuth != undefined){
			this.monitorAppAuth = param.monitorAppAuth;
		}else{
			this.monitorAppAuth = window.monitorAppAuth;
		}
		
	},
	
	/* 设置交易标示 */
	setServiceCode:function(serviceCode){
		this.serviceCode = serviceCode;
	},
	
	/* 设置交易流水 */
	setTraceID:function(traceId){
		this.traceId = traceId;
	},
		
	/* 设置地址信息 */
	setUrl:function(url){
		this.url = url;
	},
	


}
///<jscompress sourcefile="MonitorNavTable.js" />
MonitorNavTable = function(rsp){
	this.rsp = rsp;
	this.web = {};
	this.web.isCheck = true;
};

MonitorNavTable.prototype = {
	load:function(){
		this.remove();
		var div = this.getHead()+this.getBody();
		$("#"+this.web.divId).append(div);
	},
	refresh:function(){
		this.load();
	},
	remove:function(){
		$("#"+this.web.divId+" thead").remove();
		$("#"+this.web.divId+" tbody").remove();
	},
	/* 获取体信息 */
	getBody:function(){
		var div ='';
		
		div += '<tbody>';
		
		for(var j=0; j<this.rsp[0].tbody.length;j++){
			
			div += '<tr class="unread checked">';
			//页面多选
			if(this.web.isCheck){
				div += '<td class="hidden-xs"><input type="checkbox" name="checkname" class="checkbox"></td>';
			}
			
			for(var i=0;i<this.rsp[0].thead.length;i++){
				 var id = this.rsp[0].thead[i].id.toLowerCase();
				 var value = eval("this.rsp[0].tbody["+j+"]."+id);
				 div += '<td class="'+this.rsp[0].thead[i].id+'">'
				        + value
				        +'</td>';	
			}
			
			div += '</tr>';
		}	
		
		div += '</tbody>';
		
		return div;
	},
	
	/* 获取头信息 */
	getHead:function(){
		var div ='';
		
		div += '<thead>';
		
		div += '<tr class="warning">';
		//页面多选
		if(this.web.isCheck){
			div += '<td class="hidden-xs"><input type="checkbox" class="checkbox allcheck"></td>';
		}
		
		for(var i=0;i<this.rsp[0].thead.length;i++){
			 div += '<td>'+this.rsp[0].thead[i].value+'</td>';	
		}
		
		div += '</tr>';
		
		div += '</thead>';
		
		return div;
	},
	
	/* 传入页面参数 */
	setWeb:function(web){
		this.web = web;		
	}
};
///<jscompress sourcefile="MonitorTab.js" />
MonitorTab = function(element){
	this.tab = element;
};

MonitorTab.prototype = {
		
	/* 获取标签数 */	
	getTabCount:function(){
		return this.tab.length;
	}

};
///<jscompress sourcefile="MonitorTable.js" />
MonitorTable = function(element){
	this.element = element;
	this.tid = element.tid;
	this.tlable = element.tlable;
	this.thead = element.thead;
	this.tbody = element.tbody;
};

MonitorTable.prototype = {
		
	/* 获取列数 */
	getColumnCount:function(){
	   return this.thead.length;
	},
	
	/* 获取行数 */
	getRowCount:function(){
		return this.tbody.length;
	},
	
	/* 获取列标示 */
	getColumnID:function(idx){
		return this.thead[idx].id;
	},
	
	/* 获取列值 */
	getColumnValue:function(idx){
		return this.thead[idx].value;
	},
	
	/* 获取字段值 */
	getFieldValue:function(recordIdx,fieldIdx){
		var id = this.thead[fieldIdx].id;
		var value = eval("this.tbody["+recordIdx+"]."+id);
		return value;
	},
	
	/* 获取表格标示 */
	getTableId:function(){
		return this.tid;
	}
};


///<jscompress sourcefile="MonitorTableFix.js" />
MonitorTableFix = function(element){
	this.element = element;
	this.table = [];
	this.loadTable();
}

MonitorTableFix.prototype = {
	
	/* 表格装载 */		
	loadTable:function(){
	   for(var i=0;i<this.element.length;i++){
		   var mtable = new MonitorTable(this.element[i]);
		   this.table.push(mtable);
	   }
	},
	
	/* 参数弹窗 */
	property:function(){
		for(var i=0;i<this.element.length;i++){
			alert(this.table[i].tid);
			alert(this.table[i].tlable);
			alert(this.table[i].thead);
			alert(this.table[i].tbody);
		}
	}

}

///<jscompress sourcefile="MonitorCharts.js" />
MonitorCharts = function(web){
	this.web = web;
	this.checkWeb();
};

MonitorCharts.prototype = {
		
	/* 重置样式  */	
	checkWeb:function(){
		var height = 500;
		var width = document.body.clientWidth * 0.7;
		$("#"+this.web.divId).attr("style","height:"+height+"px;width:"+width+"px;");
	},	
		
	/* 统计图装载  */	
	load:function(){
		var url = window.monitorAppUrl+"ReportService";
		var barChart;
		if(window.monitorAppUrl == ""){
			barChart = new ECharts(this.web.classPath,this.web.divId);
		}else{
			barChart = new ECharts(this.web.classPath,this.web.divId,url);
		}
			
		if(this.web.param){
			if(this.web.fixParam){
				this.web.param += ","+this.web.fixParam;
			}		
			barChart.setParam(this.web.param);
		}
		barChart.pageOn(echarts);
	},
	
	/* 移除设置信息 */
	remove:function(){
		
	},
	
	/* 刷新方法 */
	refresh:function(){
		this.load();
	}
		
};
///<jscompress sourcefile="MonitorTabView.js" />
MonitorTabView = function(tab){
	this.tab = tab;
	this.view = tab.tab;
	this.divId="tab_div";
	this.navType = "tabs";
};

MonitorTabView.prototype = {
	
	/* 装载数据 */
	load:function(){
		this.remove();
		$('#'+this.divId).append(this.getDiv());
	},
	
	/* 获取总DIV */
	getDiv:function(){
		var div = "";
		div += "<div class='grid_3 grid_5'>";
		div += "<div class='but_list'>";
		div += "<div class='bs-example bs-example-tabs' role='tabpanel' data-example-id='togglable-tabs'>";
		
		div += this.getTabData();
		
		div += this.getContentData();
		
		div += "</div>";
		div += "</div>";
		div += "</div>";
		return div;
	},
	
	/* 获取标签数据信息 */
	getTabData:function(){
		var data = "";
		
		//标签页形式
		if(this.navType == "tabs"){
			data += "<ul id='myTab' class='nav nav-tabs' role='tablist'>";
		}else{
			data += "<ul id='myTab' class='nav nav-pills' role='tablist'>";
		}
		
		var first = true;
		
		for(var i=0;i<this.view.length;i++){
				
			//无下拉信息
			if(this.view[i].child.length == 0){
				if(first){
					data += "<li role='presentation' class='active'>";
					first = false;
				}else{
					data += "<li role='presentation'>";
				}
				
				data += "<a href='#"+this.view[i].id+"' id='"+this.view[i].id+"-tab' role='tab' data-toggle='tab' aria-controls='"+this.view[i].id+"' aria-expanded='true'>" +
						this.view[i].lable +
						"</a>";
				data += "</li>";
			}
			
			//存在下拉信息
			else{
				if(first){
					data += "<li class='dropdown active'>";
				}else{
					data += "<li class='dropdown'>";
				}
				data += "<a href='#' id='"+this.view[i].id+"' class='dropdown-toggle' data-toggle='dropdown'>";
				data += this.view[i].lable;
				data += " <b class='caret'></b>";
				data += "</a>";
				data += "<ul class='dropdown-menu' role='menu' aria-labelledby='"+this.view[i].id+"'>";
				for(var j=0;j<this.view[i].child.length;j++){
					if(first){
						data += "<li class='active'>";
						first = false;
					}else{
						data += "<li>";
					}			
					data += "<a href='#"+this.view[i].child[j].id+"' tabindex='-1' data-toggle='tab'>";
					data += this.view[i].child[j].lable;
					data += "</a></li>";
				}
				data += "</ul>";
				data += "</li>";
			}
			
		}
		
		data += "</ul>"
		
		return data;
	},
	
	/* 获取内容数据信息 */
	getContentData:function(){
		var content = "";
		
		content += "<div id='myTabContent' class='tab-content'>";
		
		var first = true;
		
		for(var i=0;i<this.view.length;i++){
			
			//无下拉信息
			if(this.view[i].child.length == 0){
				
				if(first){
					content += "<div role='tabpanel' class='tab-pane fade in active' id='"+this.view[i].id+"' aria-labelledby='"+this.view[i].id+"-tab'>";
					first = false;
				}else{
					content += "<div role='tabpanel' class='tab-pane fade' id='"+this.view[i].id+"' aria-labelledby='"+this.view[i].id+"-tab'>";				
				}
				
				content += "</div>";
				
			}
			
			//存在下拉信息
			else{
				
				for(var j=0;j<this.view[i].child.length;j++){
					
					if(first){
						content += "<div role='tabpanel' class='tab-pane fade in active' id='"+this.view[i].child[j].id+"' aria-labelledby='"+this.view[i].child[j].id+"-tab'>";
						first = false;
					}else{
						content += "<div role='tabpanel' class='tab-pane fade' id='"+this.view[i].child[j].id+"' aria-labelledby='"+this.view[i].child[j].id+"-tab'>";				
					}
					
					content += "</div>";				
				}			
			}
			
		}
				
		return content;
	},
	
	/* 刷新数据 */
	refresh:function(){
		this.load();
	},
	
	/* 移除数据 */
	remove:function(){
		$("#"+this.divId+" div").remove();
	},
	
	/* 设置DIV标示 */
	setDivId:function(divId){
		this.divId = divId;
	},
	
	/* 设置标签页形式 */
	setNavType:function(navType){
		this.navType = navTyep;
	}
	
};
///<jscompress sourcefile="MonitorTableFixView.js" />
MonitorTableFixView = function(element){
	this.table = element;
	this.view = [];
	this.loadView();
}

MonitorTableFixView.prototype = {
		
	/* 视图装载 */	
	loadView:function(){
		for(var i=0;i<this.table.table.length;i++){
			var tview = new MonitorTableView(this.table.table[i]);
			tview.setTableId(tview.table.tid);
			this.view.push(tview);
		}	
	},

	/* 移除页面所有表格DIV */
	remove:function(){
		$(".xs").remove();
	},
	
	/* 刷新页面数据 */
	refresh:function(){
	   this.remove();
	   this.load();
	},
	
	/* 装载页面数据 */
	load:function(){
	   this.remove();
	   
	   //装载视图
	   for(var i=0;i<this.view.length;i++){
		   this.loadTableDiv(this.view[i]);
		   this.loadTable(this.view[i]);
	   }
	   
	},
	
	/* 装载表格DIV */
	loadTableDiv:function(view){
		view.loadDiv();
	},
	
	/* 装载表格数据 */
	loadTable:function(view){
		view.load();
	},
	
	/* 设置布局 */
	setLayOut:function(layout){
		this.layout = layout;
	},
	
	/* 设置标题颜色 */
	setPanelColor:function(panelColor){
		this.panelColor = panelColor;
		 for(var i=0;i<this.view.length;i++){
			 this.view[i].setPanelColor(this.panelColor);
		 }
	},
	
	/* 设置填充DIV标示 */
	setDivId:function(divId){
		this.divId = divId;
		 for(var i=0;i<this.view.length;i++){
			 this.view[i].setDivId(this.divId);
		 }
	},
	
	/* 设置是否清除表间距 */
	setIsPadding:function(isPadding){
		this.isPadding = isPadding;
		 for(var i=0;i<this.view.length;i++){
			 this.view[i].setIsPadding(this.isPadding);
		 }
	},
	
	/* 装载后执行 */
	loadAfter:function(){
		
		//布局处理
		if(this.layout != undefined){
			var laynum = this.layout.length;
			var tablenum = this.view.length;
			for(var i=0;i<tablenum;i++){
				var j = i % laynum;
				$(".xs").eq(i).attr("class","xs col-md-"+this.layout[j]);
			}
			
		}
		
	},
	
	/* 设置按钮 */
	setButtons:function(buttons){
		this.buttons = buttons;
		for(var i=0;i<this.view.length;i++){
			 this.view[i].setButtons(this.buttons);
		}
	}
	
}
///<jscompress sourcefile="MonitorTableView.js" />
MonitorTableView = function(table){
	this.table = table;
	this.panelColor = "#000000";
	this.divId="table_div";
	this.isPadding = false;
};

MonitorTableView.prototype = {
	
	/* 设置表格标示 */	
	setTableId:function(tableId){
		this.tableId = tableId;
	},
	
	/* 设置标题颜色 */
	setPanelColor:function(panelColor){
		this.panelColor = panelColor;
	},
	
	/* 设置填充表格部分的DIV标示 */
	setDivId:function(divId){
		this.divId = divId;
	},
	
	/* 设置是否清除表内距 */
	setIsPadding:function(isPadding){
		this.isPadding = isPadding;
	},
	
	/* 设置按钮 */
	setButtons:function(buttons){
		this.buttons = buttons;
	},
	
	/* 数据装载 */
	load:function(){
		this.remove();
		var thead = this.getHead();
		var tbody = this.getBody();
		$('#'+this.tableId).append(thead);
		$('#'+this.tableId).append(tbody);
	},
	
	/* 装载DIV */
	loadDiv:function(){
		var tdiv = this.getDiv();
		$("#"+this.divId).append(tdiv);
	},
	
	/* 数据刷新 */
	refresh:function(){
		this.remove();
		this.load();
	},
	
	/* 移除页面数据 */
	remove:function(){
		$('#'+this.tableId+" thead").remove();
		$('#'+this.tableId+" tbody").remove();
	},
	
	/* 获取表格头 */
	getHead:function(){
		var thead = "";
		thead += "<thead><tr class='warning'>";
		for(var i=0;i<this.table.getColumnCount();i++){
			if(this.isPadding == true){
				thead += "<th class='padding-clear'>";
			}else{
				thead += "<th>";
			}		
			thead += this.table.getColumnValue(i);
			thead += "</th>";
		}
		thead += "</tr></thead>";
		return thead;
	},
	
	/* 获取表格体 */
	getBody:function(){
		var tbody = "";
		
		tbody += "<tbody>";		
		for(var i=0;i<this.table.getRowCount();i++){
			tbody += "<tr>";
			for(var j=0;j<this.table.getColumnCount();j++){
				if(this.isPadding == true){
					tbody += "<td class='padding-clear'>";
				}else{
					tbody += "<td>";
				}			
				tbody += this.table.getFieldValue(i,j);
				tbody += "</td>";
			}
			tbody += "</tr>";
		}
		
		tbody += "</tbody>";		
		return tbody;
	},
	
	/* 获取表格填充DIV */
	getDiv:function(){
		
		var tdiv = "";
		
		tdiv += "<div class='xs'>";
		
		tdiv += "<div class='panel panel-warning panel-clear' style='border-color: "+this.panelColor+";' data-widget='{&quot;draggable&quot;: &quot;false&quot;}' data-widget-static=''>";
		
		//表格头
		tdiv += "<div class='panel-heading' style='background-color: "+this.panelColor+";'>";
		
		//按钮处理
		if(this.buttons != undefined){
			var mtbutton = new MonitorButton(this.buttons);
			tdiv += mtbutton.getAllDiv();
		};
		
		tdiv += "<h2>"+this.table.tlable+"</h2>";
		tdiv += "</div>";
		//表格体
		tdiv += "<div class='panel-body no-padding table-responsive' style='display: block;'>";
		tdiv += "<table class='table table-striped' id='"+this.table.tid+"'></table>"
		tdiv += "</div>";
		
		tdiv += "</div>";
		
		tdiv += "</div>";
		
		return tdiv;
	}
	
};
///<jscompress sourcefile="CommonBlur.js" />
/* 唯一性焦点校验 */
function regNullBlur(){
	$(".blur-null").blur(function(e) {	
		
		var text = $(this).val();
		
		//移除所有信息
		$(this).parent().parent().parent().find(".help-block").remove();
		var msg = "";
		
		if(text == undefined || text == ""){
			msg = '<div class="col-sm-2"><p class="help-block"><i class="fa fa-times"></i></p></div>'
			$(this).parent().parent().parent().append(msg);
			$(this).parent().parent().parent().attr("class","form-group has-error");
		}else{
			msg = '<div class="col-sm-2"><p class="help-block"><i class="fa fa-check"></i></p></div>'
			$(this).parent().parent().parent().append(msg);
			$(this).parent().parent().parent().attr("class","form-group has-success");
		}		
		$(this).unbind("blur");
		$(this).unbind("focus");
		
		//注册获取焦点事件
		$(this).attr("class","form-control1 focus-on");
		regOnFocus();
		
	});
}


///<jscompress sourcefile="CommonClick.js" />
/* 注册通用方法 */
function regCommonClick(){
	regSlideUp();
	regSlideDown();
	regRemove();
}

/* 通用上拉方法 */
function regSlideUp(){
	 $(".fa-chevron-up").click(function(e) {								 			 
		 $(this).attr("class","fa fa-chevron-down");
		 $(this).parent().parent().parent().parent().find(".panel-body").slideUp(200);
		 $(this).unbind("click");
		 regSlideDown();			 
	 });	
}

/* 通用下拉方法 */
function regSlideDown(){
	$(".fa-chevron-down").click(function(e) {
		 $(this).attr("class","fa fa-chevron-up");
		 $(this).parent().parent().parent().parent().find(".panel-body").slideDown(200);
		 $(this).unbind("click");
		 regSlideUp();
	 });
}

/* 通用移除方法 */
function regRemove(){
	 $(".button-icon .fa-times").click(function(e) {			 
		 $(this).parent().parent().parent().parent().parent().remove();
	 });
}

/* 通用重置缓存方法 filterID：缓存标示 */
function regReloadCache(filterID){
	 $("#reloadCache").click(function(e){
		 
		 //调用后台
		 var msgExcute = new MonitorMsg();		 
		 var url = MUtil.getRootPath()+"/monitorService";		 
		 var param = {
			"serviceCode":"monitor",
			"classPath":"cn.lily.esb.monitor.control.node.cache.reload.CacheReloadNode",
			"traceId":"123123123",
			"url":url,
			"param":{
				"filter":filterID
			}
		 };		 
		 msgExcute.setParam(param);
		 msgExcute.post();
		 
		 $('.cacheModel').modal('hide');
		 
		 //页面刷新
		 location.reload();
	 });
}

/* 添加监控信息 */
function regMonitorAdd(){
	$("#addMonitor").click(function(e){
		
		 var ssl = "";
		 if($("#MT_comm_http").is(":checked")){
			 ssl = "http";
		 }else{
			 ssl = "https";
		 }
		
		 var msgExcute = new MonitorMsg();		 
		 var url = MUtil.getRootPath()+"/monitorService";		
		 var param = {
			"serviceCode":"monitor",
			"classPath":"cn.lily.esb.monitor.control.node.nav.MonitorNavNode",
			"traceId":"123123123",
			"monitorAppAuth":"",
			"url":url,		
			"param":{
				"appCode":$("#MT_appCode").val(),
				"appIDC":$("#MT_appIDC").val(),
				"ip":$("#MT_ip").val(),
				"port":$("#MT_port").val(),
				"ssl":ssl,
				"method":"add"
			}
		 };		 
		 msgExcute.setParam(param);
		 msgExcute.post();
		 
		 alert(msgExcute.getRspMsg());
		
		 $('.addModel').modal('hide');
		 //页面刷新
		 location.reload();
	}); 
}

/*监控系统数据刷新方法*/
function regMonitorRefresh(){
	var navTable = new Monitor();
    navTable.setParam({
		"esb":{
			"classPath":"nav.MonitorNavTableNode",
			"traceId":"123123123123",
			"monitorAppAuth":""
		},
		"web":{
			"divId":"monitorNav",
			"viewType":"navTable",
			"isCheck":true
		}
	});
	
    navTable.loadHTML();
}

/* 切换监控系统 */
function regExchange(){
	$(".exchangeMonitor").click(function(e){
		
		var appAuth = $(this).parent().parent().find(".appAuth").text().trim();
		
		$.ajax({
            type: "POST",
            url:MUtil.getRootPath()+"/frames/monitor/nav/monitor_exchange.jsp",
            processData: false,
            async: false,
            data: "appAuth="+appAuth,
            dataType: 'text', 
            success: function(data){
            	alert(data.trim());
            }
        });
		
		$('.exchangeModel').modal('hide');
		
		location.reload();
		
	});
}

/* 注册刷新 */
function regRefresh(){
	$(".monitorRef").click(function(e){
		regMonitorRefresh();
	});
}

/* 注册多选事件 */
function regCheck(){
	$(".allcheck").click(function(e){
		$("input[name='checkname']").attr('checked', this.checked);
	});
}

/*注册删除方法*/
function regDelete(){
	$(".monitorRemv").click(function(e){
		var appAuths = "";
		$("input[name='checkname']").each(function() {
			if($(this).is(":checked")){
				appAuths += $(this).parent().parent().find(".appAuth").text() + ",";
			}	        
		});
		if(appAuths == ""){
			alert("请至少选择一条记录！");
			return;
		}
		
		var msgExcute = new MonitorMsg();		 
		var url = MUtil.getRootPath()+"/monitorService";				 
		var param = {
			"serviceCode":"monitor",
			"classPath":"cn.lily.esb.monitor.control.node.nav.MonitorNavNode",
			"traceId":"123123123",
			"url":url,
			"monitorAppAuth":"",
			"param":{				
				"appAuth":appAuths,
				"method":"delete"
			}
		 };		 
		 msgExcute.setParam(param);
		 msgExcute.post();
		 
		 regMonitorRefresh();
		
	});
}

/* 注册退出方法 */
function regMonitorLoginOut(){
	$("#monitorLoginOut").click(function(e){			
		$.ajax({
            type: "POST",
            url:MUtil.getRootPath()+"/frames/monitor/nav/monitor_logout.jsp",
            processData: false,
            async: false,
            dataType: 'text', 
            success: function(data){
            	alert(data.trim());
            }
        });	
		location.reload();
	});
}

/* 重置监控缓存信息方法 */
function regMonitorReload(){
	$("#reloadMonitorCache").click(function(e){			
		$.ajax({
            type: "POST",
            url:MUtil.getRootPath()+"/frames/monitor/nav/monitor_reload.jsp",
            processData: false,
            async: false,
            dataType: 'text', 
            success: function(data){
            	alert(data.trim());
            }
        });	
		location.reload();
	});
}
///<jscompress sourcefile="CommonFucos.js" />
/*获取焦点事件*/
function regOnFocus(){
	$(".focus-on").focus(function(e) {	
		
		var text = $(this).text();
		
		$(this).parent().parent().parent().find(".help-block").remove();
		$(this).parent().parent().parent().attr("class","form-group");
		
		$(this).unbind("blur");
		$(this).unbind("focus");
		
		//注册获取焦点事件
		$(this).attr("class","form-control1 blur-null");
		regNullBlur();
		
	});
}
///<jscompress sourcefile="CommonOn.js" />
/* 页面加载方法注册 */
function regPageOn(){
	$("#monitorAppAuth").text(window.monitorAppAuth);
	$("#monitorAppIP").text(window.monitorAppIP);
	$("#monitorAppPort").text(window.monitorAppPort);
	$("#monitorAppSSL").text(window.monitorAppSSL);
	$("#monitorAppCount").text(window.monitorAppCount);
}
/* 注册页面刷新方法 */
function regPageRefresh(){
	if(window.isRefresh == "true"){
		$(document).ready(function () {  
	        setInterval("MonitorPageRefresh()", window.monitorRefreshTime);  
	    });
	}
}

/* 页面刷新方法 */
function MonitorPageRefresh(){
	window.location.reload();
}
///<jscompress sourcefile="MonitorTag.js" />
MonitorTag = function(tag){
	this.tag = tag;
	this.web = {};
};

MonitorTag.prototype = {
	
	/* 设置页面配置信息 */
	setWeb:function(web){
		this.web = web;
		
		//布局默认值
		if(this.web.layout == undefined){
			this.web.layout = [12];
		}
		
		//图标默认值
		if(this.web.ico == undefined){
			this.web.ico = ["fa fa-thumbs-up"];
		}
		
		//颜色默认值
		if(this.web.color == undefined){
			this.web.color = ["#000000"];
		}
		
		//DIV标示
		if(this.web.divId == undefined){
			this.web.divId = "tag_div";
		}
		
	},

	/* 页面装载 */
	load:function(){
		this.remove();
		this.loadTag();
	},
	
	/* 移除页面信息 */
	remove:function(){
		$('#'+this.web.divId+" div").remove();
	},	
	
	/* 装载组件信息 */
	loadTag:function(){
		$('#'+this.web.divId).append(this.getDivAll());
	},
	
	/* 刷新页面 */
	refresh:function(){
		this.load();
	},
	
	/* 获取所有DIV信息 */
	getDivAll:function(){
		var div = "";
		for(var i=0;i<this.tag.length;i++){
			div += this.getDiv(i);
		}	
		div += '<div class="clearfix"></div>';
		return div;
	},
	
	/* 获取某索引DIV信息 */
	getDiv:function(idx){
		var div = "";
		
		div += "<div class='col-md-4'>";
		div += "<div class='widget widget1'>";
		div += "<div class='r3_counter_box'>";
		
		div += '<i class="pull-left '
			+ this.web.ico[idx % this.web.ico.length]
			+' icon-rounded" style="background-color:'
			+ this.web.color[idx % this.web.color.length]
			+';"></i>';
		
		div += '<div class="stats">';		
		div += "<h5><strong>"+this.tag[idx].data+"</strong></h5>";
		div += "<span>"+this.tag[idx].lable+"</span>";
		div += '</div>';
		
		div += "</div>";
		div += "</div>";
		div += "</div>";
		
		return div;
		
	}

	

};
///<jscompress sourcefile="MonitorMapTable.js" />
MonitorMapTable = function(mapTable){
	this.mapTable = mapTable;
	this.table = {};
	this.web = {};
};

MonitorMapTable.prototype = {
	
	/* 设置Web配置信息 */	
	setWeb:function(web){
		
		this.web = web;
		
		//初始行数
		if(this.web.rowNum == undefined){
			this.web.rowNum = 6;
		}
		
		//是否存在尾行
		if(this.web.isBottom == undefined){
			this.web.isBottom = true;
		}
		
		//是否存在颜色变化
		if(this.web.isColor == undefined){
			this.web.isColor = true;
		}
		
		//是否存在标记变化
		if(this.web.isFlag == undefined){
			this.web.isFlag = true;
		}
		
		//底部信息设置
		if(this.web.bottom == undefined){
			this.web.bottom = {};
		}
		
		//底部连接信息
		if(this.web.bottom.href == undefined){
			this.web.bottom.href = ["#"];
		}
		
		//底部展示信息
		if(this.web.bottom.lable == undefined){
			this.web.bottom.lable = ["点击查看更多信息"];
		}
		
		//DIV标示
		if(this.web.divId == undefined){
			this.web.divId = "map_div";
		}
		
		//布局设置
		if(this.web.layout == undefined){
			var num = 12 / this.mapTable.length;
			this.web.layout = [num];		
		}
	},
	
	/* 移除页面DIV信息 */
    remove:function(){
    	$('#'+this.web.divId+" div").remove();
    },
	
    /* 装载信息 */
	load:function(){
		this.remove();
		//装载
		$('#'+this.web.divId).append(this.getDivAll());
	},
	
	/* 刷新信息 */
	refresh:function(){
		this.load();
	},
	
	/* 获取所有DIV信息 */
	getDivAll:function(){
		var div = "";
		for(var i=0;i<this.mapTable.length;i++){
			div += this.getDiv(i);
		}
		
		div += '<div class="clearfix"> </div>';
		return div;
	},
	
	/* 获取某个DIV信息 */
	getDiv:function(idx){
		
		var div = "";
		
		div += '<div class="col-md-';
		
		div += this.web.layout[idx % this.web.layout.length];
		
		div +=	'">';
		div += '<div class="stats-info">';
		
		div += this.getTitleDiv(idx);
		div += this.getDataDiv(idx);
		
		div += '</div>';
		div += '</div>';
		
		return div;
	},
	
	/* 获取标题DIV信息 */
	getTitleDiv:function(idx){
		var div = "";		
		div += '<div class="panel-heading">';
		div += '<h4 class="panel-title">'+this.mapTable[idx].title+'</h4>';
		div += '</div>';
		return div;
	},
	
	/* 获取数据DIV信息 */
	getDataDiv:function(idx){
		var div = '';
		
		div += '<div class="panel-body">';
		div += '<ul class="list-unstyled">';
		
		var length = this.mapTable[idx].data.length;
		
		for(var i=0;i<this.web.rowNum;i++){
			
			if(i < length){
				
				var status = this.mapTable[idx].data[i].status;
				
				div += '<li>';
				div += this.mapTable[idx].data[i].lable;
				div += '<div class="';
					
				if(this.web.isColor){
					if(status == "normal"){
						div += 'text-success';
					}else{
						div += 'text-danger';
					}					
				}
				
				div += ' pull-right">';
				div += this.mapTable[idx].data[i].value;
				
				if(this.web.isFlag){
					if(status == "normal"){
						div += '<i class="fa fa-level-down"></i>';
					}else{
						div += '<i class="fa fa-level-up"></i>';
					}				
				}
				
				div += '</div>';
				div += '</li>';
			}
			//填入空白
			else{
				div += '<li> &nbsp; </li>';
			}
			
		}
		
		//获取底部连接
		if(this.web.isBottom){
			div += this.getBottomDiv(idx);
		}
		
		div += '</ul>';
		div += '</div>';
		
		return div;
	},
	
	/* 获取底部DIV信息 */
	getBottomDiv:function(idx){
		var div = "";
		
		div += '<li class="last">';
		div += '<div class="text-success pull-right">';
		
		div += '<a class="cursor-pointer" href="';
		div += this.web.bottom.href[idx % this.web.bottom.href.length];
		div += '" style="text-decoration:none;">';
		div += this.web.bottom.lable[idx % this.web.bottom.lable.length];
		div += '</a>';
		
		div += '</div>';
		div += '</li>';
		
		return div;
	}

};
///<jscompress sourcefile="MonitorButton.js" />
MonitorButton = function(buttons){
	this.buttons = buttons;	
};

MonitorButton.prototype = {
	
	/* 是否普通按钮 */	
	isCommon:function(){
		
	},
	
	/* 获取所有DIV信息 */
	getAllDiv:function(){
		var buttonDiv = "";
		buttonDiv += "<div class='panel-ctrls' data-actions-container='' data-action-collapse='{&quot;target&quot;: &quot;.panel-body&quot;}'>";
		for(var i=0;i<this.buttons.length;i++){
			if(typeof this.buttons[i] == "object"){
				
			}else{
				if(this.buttons[i] == "reload"){
					buttonDiv += this.getReloadButtonDiv();
				}
				else if(this.buttons[i] == "slide"){
					buttonDiv += this.getSlideButtonDiv();
				}
				else if(this.buttons[i] == "close"){
					buttonDiv +=  this.getRemoveButtonDiv();
				}
			}
		}
		buttonDiv += "</div>";
		return buttonDiv;	
	},
	
	/* 获取移除按钮信息 */
	getRemoveButtonDiv:function(){
		var remove = "";
		remove += this.getCommonButtonDiv("fa fa-times");
		return remove;
	},
	
	/* 获取下拉按钮信息 */
	getSlideButtonDiv:function(){
		var slide = "";
		slide += this.getCommonButtonDiv("fa fa-chevron-up");
		return slide;
	},
	
	/* 获取重置按钮信息 */
	getReloadButtonDiv:function(){
		var reload = "";
		reload += this.getEditButtonDiv("fa fa-cog", ".cacheModel");
		return reload;
	},
	
	/* 获取通用按钮信息 */
	getCommonButtonDiv:function(cssClass){
		var common = "";
		common += "<span class='button-icon has-bg cursor-pointer'>";
		common += "<i class='"+cssClass+"'></i>";
		common += "</span>";
		common += "&nbsp;&nbsp;";
		return common;
	},
	
	/* 获取弹窗按钮信息 */
	getEditButtonDiv:function(cssClass,dataTarget){
		var edit = "";
		edit += "<span class='button-icon has-bg cursor-pointer'>";
		edit += "<a class='a_white' data-toggle='modal' data-target='"+dataTarget+"'>";
		edit += "<i class='"+cssClass+"'></i>";
		edit += "</a>";
		edit += "</span>";
		edit += "&nbsp;&nbsp;";
		return edit;
	}
		
};
///<jscompress sourcefile="Monitor.js" />
Monitor = function(){
	this.param = {};
	this.self = this;
};

Monitor.prototype = {
	
	/* 设置参数 */	
	setParam:function(param){
		this.param = param;
		
		if(this.param.esb == undefined){
			return;
		}
		
		//是否路径填充
		if(this.param.esb.isPathFill == undefined){
			this.param.esb.isPathFill = true;
		}
		
		//填充前面路径
		if(this.param.esb.classPath){
			if(this.param.esb.isPathFill){
				if(this.param.esb.classPath.indexOf("cn.lily.esb.monitor.control.node.") == -1){
					this.param.esb.classPath = "cn.lily.esb.monitor.control.node."+this.param.esb.classPath
				}
			}
		}
		
		if(this.param.esb.serviceCode == undefined){
			this.param.esb.serviceCode = "monitor";
		}	
		
	},
	
	/* 补充参数 */
	appendParam:function(msg,e){
		eval(MUtil.getObject(msg, "this.param.", "msg."));
	},

	/* 装载HTML页面 */
	loadHTML:function(){
		
		if(this.param.esb){
			//获取数据
			var msgExcute = new MonitorMsg();
			
			//设置额外参数
			var param = "{'serviceCode':this.param.esb.serviceCode,"
					    +"'traceId':this.param.esb.traceId,"
					    +"'url':this.param.esb.url,"
					    +"'classPath':this.param.esb.classPath";
			if(this.param.esb.monitorAppAuth != undefined){
				param += ",'monitorAppAuth':'"+this.param.esb.monitorAppAuth+"'";
			}
			if(this.param.esb.param !=undefined) {
				param += ",'param':{";
				for(var p in this.param.esb.param){
					param += "'"+p+"':'" + this.param.esb.param[p] +"',";
				}
				
				param = param.substring(0,param.length-1);
				
				param += "}";
			}
			
			param += "}";
			
			msgExcute.setParam(eval("("+param+")"));
			msgExcute.post();
		}
		
		if(this.param.web){
			//表格数据装载
			if(this.param.web.viewType == "table"){
				this.loadTable(msgExcute.rsp.body);
			}
			
			//表格整体装载
			if(this.param.web.viewType == "fixTable"){
				this.loadFixTable(msgExcute.rsp.body.table);
			}
			
			//标签页装载
			if(this.param.web.viewType == "tab"){
				this.loadTab(msgExcute.rsp.body.tab);
			}
			
			//装饰组件装载
			if(this.param.web.viewType == "tag"){
				this.loadTag(msgExcute.rsp.body.tag);
			}
			
			//二列表装载
			if(this.param.web.viewType == "mapTable"){
				this.loadMap(msgExcute.rsp.body.mapTable);
			}
			
			//系统多选表装载
			if(this.param.web.viewType == "navTable"){
				this.loadNav(msgExcute.rsp.body.table)
			}
			
			//通用按钮注册
			if(this.param.web.button !=undefined){
				regCommonClick();
			}
			
			//监控独有参数
			if(this.param.web.reload != undefined){
				regReloadCache(this.param.web.reload);
			}
			
			//统计图装载
			if(this.param.web.viewType == "charts"){
				this.loadCharts();
			}
			
		}
		
		//装载响应式脚本
		if(this.param.act != undefined){
			this.loadAct();
		}
	},
	
	/* 装载响应式脚本 */
	loadAct:function(){
		//装载Tab类型后续脚本
		if(this.param.act.actType == "tab"){
			this.loadTabAct();
		}
	},
	
	/* 装载统计图信息 */
	loadCharts:function(){
		if(this.param.web.url == undefined){
			this.param.web.url = MUtil.getRootPath()+"/ReportService";
		}	
		var charts = new MonitorCharts(this.param.web);
		charts.load();
	},
	
	/* 装载标签页响应脚本 */
	loadTabAct:function(){
		
		//标签页响应默认值
		if(this.param.act.clickType == undefined){
			this.param.act.clickType = "#myTab li a";
		}
		//下拉式
		if(this.param.act.clickType == "drop"){
			this.param.act.clickType = "#myTab .dropdown-menu li a";
		}
		//扩展式
		else if(this.param.act.clickType == "nav"){
			this.param.act.clickType = "#myTab li a";
		}
		
		var self = this.self;
		
		$(this.param.act.clickType).unbind("click");
		$(this.param.act.clickType).click(function (e) {
			  
			  var hrefId = $(e.target).attr("href").substring(1);
			  
			  e.preventDefault();			    		   	  		    	  	    	  
			  var table = new Monitor();
			  
			  table.setParam(self.param);
			  
			  //填充新参数
			  if(self.param.act.msg != undefined){
				  table.appendParam(self.param.act.msg,e);
			  }
			  //填充标示信息
			  if(self.param.act.href != undefined){
				  var hrefs = self.param.act.href;
				  for(var i=0;i<hrefs.length;i++){
					  eval("table.param."+hrefs[i]+" = '"+hrefId+"';");
				  }				  
			  }
			  		  
			  table.loadHTML();	
			  
			  //后续方法调用
			  if(self.param.act.after != undefined){
				  self.param.act.after(e);
			  }
		});
	},
	
	/* 根据数据装载表格 */
	loadTable:function(rspBody){
		
		//视图转换,数据存储
		var msgTable = new MonitorTable(rspBody);
				
		//页面展现
		var msgTableView = new MonitorTableView(msgTable);
		msgTableView.setTableId(this.param.web.tableId);
		
		//设置标题颜色
		if(this.param.web.panelColor!=undefined){
			msgTableView.setPanelColor(this.param.web.panelColor);
		}
		
		//设置表格填充DIV标示
		if(this.param.web.divId!=undefined){
			msgTableView.setDivId(this.param.web.divId);
		}
		
		//设置是否清除表间距
		if(this.param.web.isPadding != undefined){
			msgTableView.setIsPadding(this.param.web.isPadding);
		}
		
		//按钮设置
		if(this.param.web.button != undefined){
			msgTableView.setButtons(this.param.web.button);
		}
		
		msgTableView.load();
		
	},
	
	/* 根据数据装载多个表格 */
	loadFixTable:function(rspBodyTable){
		
		//数据存储
		var msgTable = new MonitorTableFix(rspBodyTable);	
		//数据视图
		var msgView = new MonitorTableFixView(msgTable);
		
		//布局设置
		if(this.param.web.layout != undefined){
			msgView.setLayOut(this.param.web.layout);
		}
		
		//设置标题颜色
		if(this.param.web.panelColor!=undefined){
			msgView.setPanelColor(this.param.web.panelColor);
		}
		
		//设置表格填充DIV标示
		if(this.param.web.divId!=undefined){
			msgView.setDivId(this.param.web.divId);
		}
		
		//设置是否清除表间距
		if(this.param.web.isPadding != undefined){
			msgView.setIsPadding(this.param.web.isPadding);
		}
		
		//按钮设置
		if(this.param.web.button != undefined){
			msgView.setButtons(this.param.web.button);
		}
		
		msgView.load();
		
		msgView.loadAfter();
	},
	
	/* 装载标签页 */
	loadTab:function(rspBodyTab){		
		
		var msgTab = new MonitorTab(rspBodyTab);
		
		var msgTabView = new MonitorTabView(msgTab);
		
		//设置填充DIV标示
		if(this.param.web.divId!=undefined){
			msgTabView.setDivId(this.param.web.divId);
		}
		
		//设置标签页形式
		if(this.param.web.navType!=undefined){
			msgTabView.setNavType(this.param.web.navType);
		}
		
		msgTabView.load();
	},
	
	/* 装载装饰组件 */
	loadTag:function(rspBodyTag){
		var tagView = new MonitorTag(rspBodyTag);
		
		//设置Web信息
		tagView.setWeb(this.param.web);
		
		tagView.load();
	},
	
	/* 装载二列表组件 */
	loadMap:function(rspBodyMap){
		var mapView = new MonitorMapTable(rspBodyMap);
		
		mapView.setWeb(this.param.web);
		
		mapView.load();
	},
	
	/* 装载系统多选表组件  */
	loadNav:function(rspBodyNav){
		var navView = new MonitorNavTable(rspBodyNav);
		navView.setWeb(this.param.web);
		navView.load();
	}
		
};
